#include "../include/SplitTool.h"

cppjieba::Jieba* SplitToolCppJieba::_jieBa = nullptr;

SplitToolCppJieba::SplitToolCppJieba(Configuration *conf)
: _conf(conf->getInstance())
{
    if (_jieBa == nullptr)
    {
        std::map<string,string> confMap = _conf->getConfMap();
        const char *const DICT_PATH = confMap["dictPath"].c_str();
        const char *const HMM_PATH = confMap["hmmPath"].c_str();
        const char *const USER_DICT_PATH = confMap["userDictPath"].c_str();
        const char *const IDF_PATH = confMap["idfPath"].c_str();
        const char *const STOP_WORD_PATH = confMap["stopWordPath"].c_str();

        _jieBa=new cppjieba::Jieba(DICT_PATH, HMM_PATH, USER_DICT_PATH, IDF_PATH, STOP_WORD_PATH);
        cout << "SplitToolCppJieba" << endl;
    }
        
}

vector<string> SplitToolCppJieba::cutWord(const string &sentence)
{
    
    vector<string> Words;

    _jieBa->CutAll(sentence, Words);

    return Words;
}